<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <canvas id="can" width="1000" height="1000"></canvas>
  <script>
    function draw() {
      var canvas = document.getElementById("can")
      if (canvas.getContext) {
        var ctx = canvas.getContext("2d")
        ctx.fillStyle = "rgb(200,0,0)"
        ctx.fillRect(10, 10, 55, 50) // x,y,长,宽
        ctx.fillStyle = "rgba(0,0,200,0.5)"
        ctx.fillRect(30, 30, 55, 50)
        ctx.clearRect(37, 35, 20, 20)
        ctx.strokeRect(10, 10, 75, 70)

        ctx.beginPath()
        ctx.moveTo(100, 0);
        ctx.lineTo(150, 50)
        ctx.closePath()
        ctx.stroke()

        ctx.beginPath()
        ctx.moveTo(150, 50)
        ctx.lineTo(200, 50)
        ctx.lineTo(175, 75)
        ctx.lineTo(150, 50)
        ctx.fillStyle = "rgba(0,200,0,0.5)"
        ctx.fill()
        ctx.stroke()

        ctx.beginPath()
        ctx.arc(60, 60, 40, 0, Math.PI / 2, false)
        ctx.stroke()

        // ctx.beginPath();
        // ctx.arc(150, 50, 40, 0, -Math.PI / 2, true);
        // ctx.closePath();
        // ctx.stroke(); 

        // ctx.beginPath()
        // ctx.arc(150, 50, 40, 0, -Math.PI / 2, Math.PI / 2, false)
        // ctx.fill()

        // ctx.beginPath()
        // ctx.arc(150, 150, 40, 0, Math.PI, false)
        // ctx.fill() 

        ctx.beginPath()
        ctx.moveTo(250, 50)
        ctx.arcTo(300, 50, 300, 100, 50)
        ctx.stroke()

        ctx.beginPath();
        ctx.rect(250, 50, 10, 10);
        ctx.rect(300, 50, 10, 10)
        ctx.rect(300, 100, 10, 10)
        ctx.fill()

        ctx.beginPath()
        ctx.moveTo(50,100)
        ctx.arc(50,150,50,0,2*Math.PI)
        ctx.stroke()

        ctx.setLineDash([5,5])
        ctx.lineDashOffset = -0
        ctx.strokeRect(150,150,50,50)

        ctx.font = "30px sans-serif"
        ctx.fillText("测试",50,300)
        ctx.strokeText("测试",50,350)

        
        
      } else {

      }
    }
    draw()
  </script>
</body>

</html>